<?xml version="1.0" encoding="ascii"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
          "DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
  <title>easygui.EgStore</title>
  <link rel="stylesheet" href="epydoc.css" type="text/css" />
  <script type="text/javascript" src="epydoc.js"></script>
</head>

<body bgcolor="white" text="black" link="blue" vlink="#204080"
      alink="#204080">
<!-- ==================== NAVIGATION BAR ==================== -->
<table class="navbar" border="0" width="100%" cellpadding="0"
       bgcolor="#a0c0ff" cellspacing="0">
  <tr valign="middle">
  <!-- Home link -->
      <th>&nbsp;&nbsp;&nbsp;<a
        href="easygui-module.html">Home</a>&nbsp;&nbsp;&nbsp;</th>

  <!-- Tree link -->
      <th>&nbsp;&nbsp;&nbsp;<a
        href="module-tree.html">Trees</a>&nbsp;&nbsp;&nbsp;</th>

  <!-- Index link -->
      <th>&nbsp;&nbsp;&nbsp;<a
        href="identifier-index.html">Indices</a>&nbsp;&nbsp;&nbsp;</th>

  <!-- Help link -->
      <th>&nbsp;&nbsp;&nbsp;<a
        href="help.html">Help</a>&nbsp;&nbsp;&nbsp;</th>

      <th class="navbar" width="100%"></th>
  </tr>
</table>
<table width="100%" cellpadding="0" cellspacing="0">
  <tr valign="top">
    <td width="100%">
      <span class="breadcrumbs">
        <a href="easygui-module.html">Module&nbsp;easygui</a> ::
        Class&nbsp;EgStore
      </span>
    </td>
    <td>
      <table cellpadding="0" cellspacing="0">
        <!-- hide/show private -->
        <tr><td align="right"><span class="options">[<a href="javascript:void(0);" class="privatelink"
    onclick="toggle_private();">hide&nbsp;private</a>]</span></td></tr>
        <tr><td align="right"><span class="options"
            >[<a href="frames.html" target="_top">frames</a
            >]&nbsp;|&nbsp;<a href="easygui.EgStore-class.html"
            target="_top">no&nbsp;frames</a>]</span></td></tr>
      </table>
    </td>
  </tr>
</table>
<!-- ==================== CLASS DESCRIPTION ==================== -->
<h1 class="epydoc">Class EgStore</h1><p class="nomargin-top"><span class="codelink"><a href="easygui-pysrc.html#EgStore">source&nbsp;code</a></span></p>
<p>A class to support persistent storage.</p>
  <p>You can use EgStore to support the storage and retrieval of user 
  settings for an EasyGui application.</p>
  <p># Example A 
  #----------------------------------------------------------------------- 
  # define a class named Settings as a subclass of EgStore 
  #----------------------------------------------------------------------- 
  class Settings(EgStore): :</p>
<pre class="literalblock">
       def __init__(self, filename):  # filename is required
               #-------------------------------------------------
               # Specify default/initial values for variables that
               # this particular application wants to remember.
               #-------------------------------------------------
               self.userId = &quot;&quot;
               self.targetServer = &quot;&quot;

               #-------------------------------------------------
               # For subclasses of EgStore, these must be
               # the last two statements in  __init__
               #-------------------------------------------------
               self.filename = filename  # this is required
               self.restore()            # restore values from the storage file if possible
</pre>
  <p># Example B 
  #----------------------------------------------------------------------- 
  # create settings, a persistent Settings object 
  #----------------------------------------------------------------------- 
  settingsFile = &quot;myApp_settings.txt&quot; settings = 
  Settings(settingsFile)</p>
  <p>user    = &quot;obama_barak&quot; server  = &quot;whitehouse1&quot; 
  settings.userId = user settings.targetServer = server settings.store()
  # persist the settings</p>
  <p># run code that gets a new value for userId, and persist the settings 
  user    = &quot;biden_joe&quot; settings.userId = user 
  settings.store()</p>
  <p># Example C 
  #----------------------------------------------------------------------- 
  # recover the Settings instance, change an attribute, and store it again.
  #----------------------------------------------------------------------- 
  settings = Settings(settingsFile) settings.userId = 
  &quot;vanrossum_g&quot; settings.store()</p>

<!-- ==================== INSTANCE METHODS ==================== -->
<a name="section-InstanceMethods"></a>
<table class="summary" border="1" cellpadding="3"
       cellspacing="0" width="100%" bgcolor="white">
<tr bgcolor="#70b0f0" class="table-header">
  <td colspan="2" class="table-header">
    <table border="0" cellpadding="0" cellspacing="0" width="100%">
      <tr valign="top">
        <td align="left"><span class="table-header">Instance Methods</span></td>
        <td align="right" valign="top"
         ><span class="options">[<a href="#section-InstanceMethods"
         class="privatelink" onclick="toggle_private();"
         >hide private</a>]</span></td>
      </tr>
    </table>
  </td>
</tr>
<tr>
    <td width="15%" align="right" valign="top" class="summary">
      <span class="summary-type">&nbsp;</span>
    </td><td class="summary">
      <table width="100%" cellpadding="0" cellspacing="0" border="0">
        <tr>
          <td><span class="summary-sig"><a name="__init__"></a><span class="summary-sig-name">__init__</span>(<span class="summary-sig-arg">self</span>,
        <span class="summary-sig-arg">filename</span>)</span></td>
          <td align="right" valign="top">
            <span class="codelink"><a href="easygui-pysrc.html#EgStore.__init__">source&nbsp;code</a></span>
            
          </td>
        </tr>
      </table>
      
    </td>
  </tr>
<tr>
    <td width="15%" align="right" valign="top" class="summary">
      <span class="summary-type">&nbsp;</span>
    </td><td class="summary">
      <table width="100%" cellpadding="0" cellspacing="0" border="0">
        <tr>
          <td><span class="summary-sig"><a href="easygui.EgStore-class.html#restore" class="summary-sig-name">restore</a>(<span class="summary-sig-arg">self</span>)</span><br />
      Set the values of whatever attributes are recoverable from the pickle
      file.</td>
          <td align="right" valign="top">
            <span class="codelink"><a href="easygui-pysrc.html#EgStore.restore">source&nbsp;code</a></span>
            
          </td>
        </tr>
      </table>
      
    </td>
  </tr>
<tr>
    <td width="15%" align="right" valign="top" class="summary">
      <span class="summary-type">&nbsp;</span>
    </td><td class="summary">
      <table width="100%" cellpadding="0" cellspacing="0" border="0">
        <tr>
          <td><span class="summary-sig"><a href="easygui.EgStore-class.html#store" class="summary-sig-name">store</a>(<span class="summary-sig-arg">self</span>)</span><br />
      Save the attributes of the EgStore object to a pickle file.</td>
          <td align="right" valign="top">
            <span class="codelink"><a href="easygui-pysrc.html#EgStore.store">source&nbsp;code</a></span>
            
          </td>
        </tr>
      </table>
      
    </td>
  </tr>
<tr>
    <td width="15%" align="right" valign="top" class="summary">
      <span class="summary-type">&nbsp;</span>
    </td><td class="summary">
      <table width="100%" cellpadding="0" cellspacing="0" border="0">
        <tr>
          <td><span class="summary-sig"><a href="easygui.EgStore-class.html#kill" class="summary-sig-name">kill</a>(<span class="summary-sig-arg">self</span>)</span><br />
      Delete my persistent file (i.e.</td>
          <td align="right" valign="top">
            <span class="codelink"><a href="easygui-pysrc.html#EgStore.kill">source&nbsp;code</a></span>
            
          </td>
        </tr>
      </table>
      
    </td>
  </tr>
<tr>
    <td width="15%" align="right" valign="top" class="summary">
      <span class="summary-type">&nbsp;</span>
    </td><td class="summary">
      <table width="100%" cellpadding="0" cellspacing="0" border="0">
        <tr>
          <td><span class="summary-sig"><a name="__str__"></a><span class="summary-sig-name">__str__</span>(<span class="summary-sig-arg">self</span>)</span><br />
      return my contents as a string in an easy-to-read format.</td>
          <td align="right" valign="top">
            <span class="codelink"><a href="easygui-pysrc.html#EgStore.__str__">source&nbsp;code</a></span>
            
          </td>
        </tr>
      </table>
      
    </td>
  </tr>
</table>
<!-- ==================== METHOD DETAILS ==================== -->
<a name="section-MethodDetails"></a>
<table class="details" border="1" cellpadding="3"
       cellspacing="0" width="100%" bgcolor="white">
<tr bgcolor="#70b0f0" class="table-header">
  <td colspan="2" class="table-header">
    <table border="0" cellpadding="0" cellspacing="0" width="100%">
      <tr valign="top">
        <td align="left"><span class="table-header">Method Details</span></td>
        <td align="right" valign="top"
         ><span class="options">[<a href="#section-MethodDetails"
         class="privatelink" onclick="toggle_private();"
         >hide private</a>]</span></td>
      </tr>
    </table>
  </td>
</tr>
</table>
<a name="restore"></a>
<div>
<table class="details" border="1" cellpadding="3"
       cellspacing="0" width="100%" bgcolor="white">
<tr><td>
  <table width="100%" cellpadding="0" cellspacing="0" border="0">
  <tr valign="top"><td>
  <h3 class="epydoc"><span class="sig"><span class="sig-name">restore</span>(<span class="sig-arg">self</span>)</span>
  </h3>
  </td><td align="right" valign="top"
    ><span class="codelink"><a href="easygui-pysrc.html#EgStore.restore">source&nbsp;code</a></span>&nbsp;
    </td>
  </tr></table>
  
  <p>Set the values of whatever attributes are recoverable from the pickle 
  file.</p>
  <p>Populate the attributes (the __dict__) of the EgStore object from     
  the attributes (the __dict__) of the pickled object.</p>
  <p>If the pickled object has attributes that have been initialized in the
  EgStore object, then those attributes of the EgStore object will be 
  replaced by the values of the corresponding attributes in the pickled 
  object.</p>
  <p>If the pickled object is missing some attributes that have been 
  initialized in the EgStore object, then those attributes of the EgStore 
  object will retain the values that they were initialized with.</p>
  <p>If the pickled object has some attributes that were not initialized in
  the EgStore object, then those attributes will be ignored.</p>
  <p>IN SUMMARY:</p>
  <p>After the recover() operation, the EgStore object will have all, and 
  only, the attributes that it had when it was initialized.</p>
  <p>Where possible, those attributes will have values recovered from the 
  pickled object.</p>
  <dl class="fields">
  </dl>
</td></tr></table>
</div>
<a name="store"></a>
<div>
<table class="details" border="1" cellpadding="3"
       cellspacing="0" width="100%" bgcolor="white">
<tr><td>
  <table width="100%" cellpadding="0" cellspacing="0" border="0">
  <tr valign="top"><td>
  <h3 class="epydoc"><span class="sig"><span class="sig-name">store</span>(<span class="sig-arg">self</span>)</span>
  </h3>
  </td><td align="right" valign="top"
    ><span class="codelink"><a href="easygui-pysrc.html#EgStore.store">source&nbsp;code</a></span>&nbsp;
    </td>
  </tr></table>
  
  <p>Save the attributes of the EgStore object to a pickle file. Note that 
  if the directory for the pickle file does not already exist, the store 
  operation will fail.</p>
  <dl class="fields">
  </dl>
</td></tr></table>
</div>
<a name="kill"></a>
<div>
<table class="details" border="1" cellpadding="3"
       cellspacing="0" width="100%" bgcolor="white">
<tr><td>
  <table width="100%" cellpadding="0" cellspacing="0" border="0">
  <tr valign="top"><td>
  <h3 class="epydoc"><span class="sig"><span class="sig-name">kill</span>(<span class="sig-arg">self</span>)</span>
  </h3>
  </td><td align="right" valign="top"
    ><span class="codelink"><a href="easygui-pysrc.html#EgStore.kill">source&nbsp;code</a></span>&nbsp;
    </td>
  </tr></table>
  
  <p>Delete my persistent file (i.e. pickle file), if it exists.</p>
  <dl class="fields">
  </dl>
</td></tr></table>
</div>
<br />
<!-- ==================== NAVIGATION BAR ==================== -->
<table class="navbar" border="0" width="100%" cellpadding="0"
       bgcolor="#a0c0ff" cellspacing="0">
  <tr valign="middle">
  <!-- Home link -->
      <th>&nbsp;&nbsp;&nbsp;<a
        href="easygui-module.html">Home</a>&nbsp;&nbsp;&nbsp;</th>

  <!-- Tree link -->
      <th>&nbsp;&nbsp;&nbsp;<a
        href="module-tree.html">Trees</a>&nbsp;&nbsp;&nbsp;</th>

  <!-- Index link -->
      <th>&nbsp;&nbsp;&nbsp;<a
        href="identifier-index.html">Indices</a>&nbsp;&nbsp;&nbsp;</th>

  <!-- Help link -->
      <th>&nbsp;&nbsp;&nbsp;<a
        href="help.html">Help</a>&nbsp;&nbsp;&nbsp;</th>

      <th class="navbar" width="100%"></th>
  </tr>
</table>
<table border="0" cellpadding="0" cellspacing="0" width="100%%">
  <tr>
    <td align="left" class="footer">
    Generated by Epydoc 3.0.1 on Sun Jan 02 19:19:38 2011
    </td>
    <td align="right" class="footer">
      <a target="mainFrame" href="http://epydoc.sourceforge.net"
        >http://epydoc.sourceforge.net</a>
    </td>
  </tr>
</table>

<script type="text/javascript">
  <!--
  // Private objects are initially displayed (because if
  // javascript is turned off then we want them to be
  // visible); but by default, we want to hide them.  So hide
  // them unless we have a cookie that says to show them.
  checkCookie();
  // -->
</script>
</body>
</html>
